home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / ACORNUSERS / EMULATOR / MAGICKIT / assembler / c / output < prev    next >
Text File  |  1998-04-27  |  2KB  |  115 lines

  1. #include <stdio.h>
  2. #include "defs.h"
  3. #include "externs.h"
  4.  
  5. /* printline prints the contents of prlnbuf */
  6.  
  7. println()
  8. {
  9.     if (!xlist || !clist || (expand_macro && !mlist))
  10.         return;
  11.     fprintf(lptr, "%s\n", prlnbuf);
  12. }
  13.  
  14. /* clearline clear prlnbuf */
  15.  
  16. clearln()
  17. {
  18.     int i;
  19.  
  20.     for (i = 0; i < SFIELD; i++)
  21.         prlnbuf[i] = ' ';
  22.     prlnbuf[i] = 0;
  23. }
  24.  
  25. /* error printing routine */
  26.  
  27. error(char *stptr)
  28. {
  29.     int i, temp;
  30.  
  31.         if (switch_throwback == 1) {
  32.             switch_throwback++;
  33.             DDEUtils_ThrowbackStart();
  34.         }
  35.  
  36.     /*  Put the source line number into prlnbuf. */
  37.  
  38.     i = 4;
  39.     temp = slnum;
  40.     while (temp != 0) {
  41.         prlnbuf[i--] = temp % 10 + '0';
  42.         temp /= 10;
  43.     }
  44.  
  45.     /*  Update the name of the current file. */
  46.  
  47.     if (infile_error != infile_num) {
  48.             if (switch_throwback) DDEUtils_ThrowbackSend_Processing(input_file[infile_num].name);
  49.         fprintf(stdout, "#[%i]   %s\n", infile_num, input_file[infile_num].name);
  50.         infile_error = infile_num;
  51.     }
  52.  
  53.     /*  Output the line and the error message. */
  54.  
  55.     loadlc(loccnt, 0);
  56.     fprintf(stdout, "%s\n", prlnbuf);
  57.     fprintf(stdout, "       %s\n", stptr);
  58.     if (switch_throwback) DDEUtils_ThrowbackSend_Error(input_file[infile_num].name, slnum, 1, stptr);
  59.     errcnt++;
  60. }
  61.  
  62. /* load 16 bit value in printable form into prlnbuf */
  63.  
  64. loadlc(int offset, int f)
  65. {
  66.     int    i;
  67.  
  68.     i = 7 + 9*f;
  69.  
  70.     if (!f) {
  71.         hexcon(2, bank);
  72.         prlnbuf[i++] = hex[1];
  73.         prlnbuf[i++] = hex[2];
  74.         prlnbuf[i++] = ':';
  75.         offset |= page << 13;
  76.     }
  77.     hexcon(4, offset);
  78.     prlnbuf[i++] = hex[1];
  79.     prlnbuf[i++] = hex[2];
  80.     prlnbuf[i++] = hex[3];
  81.     prlnbuf[i]   = hex[4];
  82. }
  83.  
  84. /* load value in hex into prlnbuf[contents[i]] */
  85. /* and output hex characters to obuf if LAST_PASS & oflag == 1 */
  86.  
  87. loadv(int offset, int val, int f)
  88. {
  89.     hexcon(2, val);
  90.     prlnbuf[16 + 3*f] = hex[1];
  91.     prlnbuf[17 + 3*f] = hex[2];
  92.  
  93.     if (pass == LAST_PASS) {
  94.         if (offset < 0x2000) {
  95.             rom[bank][offset] = val;
  96.             if (bank > max_bank)
  97.                 max_bank = bank;
  98.         }
  99.     }
  100. }
  101.  
  102. /* convert number supplied as argument to hexadecimal in hex[digit] (lsd)
  103.         through hex[1] (msd)        */
  104.  
  105. hexcon(int digit, int num)
  106. {
  107.     for (; digit > 0; digit--) {
  108.         hex[digit] = (num & 0x0f) + '0';
  109.         if (hex[digit] > '9')
  110.             hex[digit] += 'A' -'9' - 1;
  111.         num >>= 4;
  112.     }
  113. }
  114.  
  115.